package com.lvshou.medicalkit.service;

import android.app.IntentService;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.os.Build;

import com.common.libhttp.retrofit.RetrofitManager;
import com.lvshou.medicalkit.constants.Constants;

/**
 * 初始化配置service
 *
 * @author Administrator
 * @Date 2019/3/6
 */
public class InitializeService extends IntentService {
    private static final String ACTION_INIT_WHEN_APP_CREATE = "com.lvshou.medicalkit.service";

    public InitializeService() {
        this("InitializeService");
    }

    public InitializeService(String name) {
        super(name);
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        if (intent != null) {
            final String action = intent.getAction();
            if (ACTION_INIT_WHEN_APP_CREATE.equals(action)) {
                performInit();
            }
        }
    }

    private void performInit() {
        //此处进行第三方sdk初始化
//        LitePal.initialize(this.getApplicationContext());

    }

    public static void start(Context context) {
        Intent intent = new Intent(context, InitializeService.class);
        intent.setAction(ACTION_INIT_WHEN_APP_CREATE);
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//            context.startForegroundService(intent);
//        } else {
            context.startService(intent);
//        }
    }
}
